#ifndef __MOD_CANOPEN_H__
#define __MOD_CANOPEN_H__

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include "bsp/bsp.h"

enum SDO_FUNC {
    READ_REQ = 0x40,
    READ_REP_BYTE_1 = 0x4F,
    READ_REP_BYTE_2 = 0x4B,
    READ_REP_BYTE_3 = 0x47,
    READ_REP_BYTE_4 = 0x43,

    WRITE_REQ_BYTE_1 = 0x2F,
    WRITE_REQ_BYTE_2 = 0x2B,
    WRITE_REQ_BYTE_3 = 0x27,
    WRITE_REQ_BYTE_4 = 0x23,
    WRITE_REP = 0x60,
    WRITE_REP_ERROR = 0x80,
};

enum CID_FUNC {
    TXPDO0 = 0x180,
    RXPDO0 = 0x200,
    TXPDO1 = 0x280,
    RXPDO1 = 0x300,
    TXPDO2 = 0x380,
    RXPDO2 = 0x400,
    TXPDO3 = 0x480,
    RXPDO3 = 0x500,
    TXSDO = 0x580,
    RXSDO = 0x600,
};


bool mod_canopen_write_sdo(uint16_t m_id, uint32_t address, uint8_t type, uint32_t data);
bool mod_canopen_read_sdo(uint16_t m_id, uint32_t address, uint8_t type, uint32_t *data);
bool mod_canopen_start_node(int8_t id);
bool mod_canopen_sync(void);
bool mod_canopen_write_rxpdo(uint16_t m_id, enum CID_FUNC channel, uint8_t *data, uint8_t dsize);

#ifdef __cplusplus
}
#endif /* __cplusplus */



#endif
